package com.ruoyi.performance.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.performance.domain.SysPerformanceAppraisal;
import com.ruoyi.performance.service.ISysPerformanceAppraisalService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 考核项目管理Controller
 * 
 * @author ruoyi
 * @date 2024-03-23
 */
@RestController
@RequestMapping("/appraisal")
public class SysPerformanceAppraisalController extends BaseController
{
    @Autowired
    private ISysPerformanceAppraisalService sysPerformanceAppraisalService;
    /**
     * 查询考核项目名称
     */
    @RequiresPermissions("performance:appraisal:list")
    @GetMapping("/getAssessmentItems")
    public List<SysPerformanceAppraisal> getAssessmentItems(SysPerformanceAppraisal sysPerformanceAppraisal)
    {


        return sysPerformanceAppraisalService.getAssessmentItems();
    }

    /**
     * 查询考核项目管理列表
     */
    @RequiresPermissions("performance:appraisal:list")
    @GetMapping("/list")
    public TableDataInfo list(SysPerformanceAppraisal sysPerformanceAppraisal)
    {
        startPage();
        List<SysPerformanceAppraisal> list = sysPerformanceAppraisalService.selectSysPerformanceAppraisalList(sysPerformanceAppraisal);
        return getDataTable(list);
    }

    /**
     * 导出考核项目管理列表
     */
    @RequiresPermissions("performance:appraisal:export")
    @Log(title = "考核项目管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysPerformanceAppraisal sysPerformanceAppraisal)
    {
        List<SysPerformanceAppraisal> list = sysPerformanceAppraisalService.selectSysPerformanceAppraisalList(sysPerformanceAppraisal);
        ExcelUtil<SysPerformanceAppraisal> util = new ExcelUtil<SysPerformanceAppraisal>(SysPerformanceAppraisal.class);
        util.exportExcel(response, list, "考核项目管理数据");
    }

    /**
     * 获取考核项目管理详细信息
     */
    @RequiresPermissions("performance:appraisal:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysPerformanceAppraisalService.selectSysPerformanceAppraisalById(id));
    }

    /**
     * 新增考核项目管理
     */
    @RequiresPermissions("performance:appraisal:add")
    @Log(title = "考核项目管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysPerformanceAppraisal sysPerformanceAppraisal)
    {
        return toAjax(sysPerformanceAppraisalService.insertSysPerformanceAppraisal(sysPerformanceAppraisal));
    }

    /**
     * 修改考核项目管理
     */
    @RequiresPermissions("performance:appraisal:edit")
    @Log(title = "考核项目管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysPerformanceAppraisal sysPerformanceAppraisal)
    {
        return toAjax(sysPerformanceAppraisalService.updateSysPerformanceAppraisal(sysPerformanceAppraisal));
    }

    /**
     * 删除考核项目管理
     */
    @RequiresPermissions("performance:appraisal:remove")
    @Log(title = "考核项目管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysPerformanceAppraisalService.deleteSysPerformanceAppraisalByIds(ids));
    }
}
